const secret = 'as35sdf45sd46f'
const key = 'key'

function b64Encode(str) {
    return btoa(encodeURIComponent(str));
}

function b64Decode(str) {
    if(!str) return null
    return decodeURIComponent(atob(str));
}

export function getToken() {
    return JSON.parse(b64Decode(localStorage.getItem(key)))
}

export function setToken(token) {
    localStorage.setItem(key, b64Encode(JSON.stringify(token)))
}

export function removeToken() {
    localStorage.removeItem('accessToken')
    return localStorage.removeItem(key)
}
